Skip to content

test(ingestion): assert the fixed Excel behaviour, not the defect - #485

Merged
kevincostner17 merged 1 commit into
mainfrom
fix/ingestion-tests-after-excel-fix
Sep 20, 2026
Merged

kevincostner17 merged 1 commit into
mainfrom
fix/ingestion-tests-after-excel-fix

Conversation

@kevincostner17

Copy link
Copy Markdown
Contributor

main is red — this fixes it

main at c0fbb08: 7064 passed, 2 failed.

FAILED tests/test_ingestion_roundtrip.py::test_excel_ingestion_drops_leading_zeros_that_the_csv_path_preserves
FAILED tests/test_ingestion_roundtrip.py::test_csv_to_excel_round_trip_loses_the_leading_zeros_csv_had_kept

Why

#478 found that preserve_leading_zeros was a no-op for clean_excel and — following the repo's convention of not using xfail — pinned the defect as it behaved:

assert list(fd.clean_excel(xlsx)["zip"]) == [2134, 501, 10001]  # DEFECT

#480 then fixed that defect.

Each PR was green on its own branch, and each was rebased on a main that did not contain the other, so nothing caught the pair until both had landed. Those two assertions were tripwires for the fix, and the fix duly tripped them.

The change

Both assertions now describe the repaired behaviour, and each docstring keeps the history so the tests still explain why they exist.

The round-trip case gains nothing artificial — it simply asserts that the Excel hop no longer undoes a correct CSV clean, which is the property that was missing in the first place. The opt-out (preserve_leading_zeros=False) and explicit-dtype paths are asserted alongside, so the fix cannot drift into applying unconditionally.

Verification

  • tests/test_ingestion_roundtrip.py: 22 passed.
  • Full suite py3.12: 7066 passed, 27 skipped, 0 failed, coverage 94.21%.
  • ruff check . clean repo-wide.
  • No library code changed.

Process note

A green CI check on each PR independently is not evidence that main will be green after both land. When a test pins a defect as current behaviour, it is a merge-order dependency — the second of the pair needs a rebase onto the first and a re-run before merging.

main went red at c0fbb08: 7064 passed, 2 failed.

#478 found that preserve_leading_zeros was a no-op for clean_excel and, following
the repo's convention of not using xfail, pinned the defect as it behaved:

    assert list(fd.clean_excel(xlsx)["zip"]) == [2134, 501, 10001]  # DEFECT

#480 then fixed that defect. Each PR was green on its own branch, and each was
rebased on a main that did not contain the other, so nothing caught the pair
until both had landed. The two assertions were tripwires for the fix, and the
fix duly tripped them.

Both now assert the repaired behaviour, and each docstring keeps the history so
the tests still explain why they exist. The round-trip case gains nothing
artificial -- it simply asserts that the Excel hop no longer undoes a correct
CSV clean, which is the property that was missing in the first place. The
opt-out and explicit-dtype paths are asserted alongside, so the fix cannot drift
into applying unconditionally.

Full suite 7066 passed / 0 failed, coverage 94.21%; ruff clean repo-wide.
@coderabbitai

coderabbitai Bot commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 3b42bb79-2724-4fa4-9b80-d5a7c70fc780


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kevincostner17
kevincostner17 merged commit b2901ff into main Sep 20, 2026
19 checks passed
kevincostner17 added a commit that referenced this pull request Sep 20, 2026
A numeric code column with one blank cell loads from CSV as float64, so
Series.astype("string") renders 10000266 as "10000266.0" and the trailing 0
reads as an extra digit. Every row of a perfectly valid column then fails a
digit-only pattern:

    GS1-008  gpc_brick_code, int64   -> passed,  0 violations, trust 0.25
    GS1-008  gpc_brick_code, float64 -> FAILED,  3 violations, trust 0.0625

Same codes, same rule, four-fold trust drop, decided by whether one cell
happened to be blank. Both regex rules in the repo were affected: GS1-008
([0-9]{8}) and FIN-008 ([A-Za-z0-9]{4,12}).

The repository had already settled the intended behaviour. retail/validator.py
carried _integral_float_text for exactly this case on the GTIN checks, and its
docstring describes this same CSV-blank-cell scenario -- the shared rule engine
simply never used it. The helper now lives in domains/base.py as
integral_float_text, _check_regex applies it, and retail imports it rather than
keeping a second copy.

Deliberately narrow: only an integral, finite float is rewritten. A genuine
decimal keeps its fraction, NaN and ±inf pass through (int(nan) would raise),
and text, integers and None are untouched -- so zero-padded strings keep their
padding and a real violation is still reported. Verified: a frame of genuinely
invalid codes still fails with all four rows flagged.

Three assertions in the new test file fail on main, across both affected rules.

Also updates test_domain_validation_lane.py, which pinned this defect as
current behaviour when #482 found it. That test is a tripwire for the fix and
the fix duly tripped it, so it now asserts the repaired behaviour with the
history kept in its docstring. This is the second time a pinned-defect test has
had to be flipped by the fix that resolved it (see #485); worth checking for
others before landing a behaviour change.

Full suite 7107 passed / 0 failed, coverage 94.94%; gauntlet gates all pass;
ruff clean repo-wide.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant